//
//  CYPersonAttestationVC.m
//  CreditAddressBook
//
//  Created by Mosu&Cuu on 16/6/13.
//  Copyright © 2016年 Lee. All rights reserved.
//

#import "CYPersonAttestationVC.h"
#import "CYXueliVC.h"
#import "CYHuzhaoVC.h"
#import "CYHunyinVC.h"
#import "CYXinyongVC.h"
#import "CYHujiVC.h"
#import "CYJiazhaoVC.h"
#import "CYFangchanVC.h"
#import "CYCheliangVC.h"
#import "CYGongxinVC.h"
#import "CYGetiVC.h"
#import "LEBarButtonItem.h"
#import "CYUser.h"
#import "CYLoginHttpTool.h"
#import "NSObject+MJKeyValue.h"
#import "MBProgressHUD+LE.h"
#import "CYJsonInfo.h"
#import "UIAlertView+Block.h"
#import "CYDES3Util.h"


@interface CYPersonAttestationVC ()
@property (weak, nonatomic) IBOutlet UIImageView *gerenleiStatueImage;
@property (weak, nonatomic) IBOutlet UIImageView *assetstatueimageView;
@property (weak, nonatomic) IBOutlet UIImageView *workstatueimageView;
@property (nonatomic, strong) NSMutableArray *xueliSubmitArray;
@property (nonatomic, strong) NSMutableArray *huzhaoSubmitArray;
@property (nonatomic, strong) NSMutableArray *hunyinSubmitArray;
@property (nonatomic, strong) NSMutableArray *xinyongSubmitArray;
@property (nonatomic, strong) NSMutableArray *hujiSubmitArray;
@property (nonatomic, strong) NSMutableArray *jiazhaoSubmitArray;
@property (nonatomic, strong) NSMutableArray *gerenleiSubmitArray;
@property (nonatomic, strong) NSArray *qianzhengArray;
@property (nonatomic, strong) NSArray *xinyongArray;
@property (nonatomic, strong) NSArray *hujijiatingArray;

@property (nonatomic, strong) NSArray *fangchanzmArray;
@property (nonatomic, strong) NSArray *fangchanhaunjingArray;
@property (nonatomic, strong) NSArray *fangchanshouchiArray;
@property (nonatomic, strong) NSArray *cheliangbaipaiArray;
@property (nonatomic, strong) NSArray *cheliangheyingArray;
@property (nonatomic, strong) NSArray *cheliangshouchiArray;

@property (nonatomic, strong) NSMutableArray *assetSubmitArray;


@property (nonatomic, strong) NSMutableArray *gongxinSubmitArray;
@property (nonatomic, strong) NSMutableArray *workSubmitArray;
@property (nonatomic, strong) NSArray *gongxindanweihuanjingArray;
@property (nonatomic, strong) NSArray *gongxinbangonghuanjingArray;
@property (nonatomic, strong) NSArray *getibaipaiUrl;
@property (nonatomic, strong) NSArray *getihuanjingUrl;
@property (nonatomic, strong) NSArray *getimentouUrl;
@property (nonatomic, strong) NSArray *getishouchiUrl;

@property (nonnull, strong) UITextField *dealcodeTF;

@property (nonatomic, strong) NSString *popstatues;




@end

@implementation CYPersonAttestationVC

- (void)viewDidLoad {
    [super viewDidLoad];
     self.title = @"人工认证";
     
     _xueliSubmitArray = [[NSMutableArray alloc]init];
     _huzhaoSubmitArray = [[NSMutableArray alloc]init];
     _hunyinSubmitArray = [[NSMutableArray alloc]init];
     _hujiSubmitArray = [[NSMutableArray alloc]init];
     _xinyongSubmitArray = [[NSMutableArray alloc]init];
     _jiazhaoSubmitArray = [[NSMutableArray alloc]init];
     _gerenleiSubmitArray = [[NSMutableArray alloc]init];
     _assetSubmitArray = [[NSMutableArray alloc]init];
     _gongxinSubmitArray = [[NSMutableArray alloc]init];
     _workSubmitArray = [[NSMutableArray alloc]init];
     
     [self loadbtn];
     
     [self loadstatues];
     [self setupNoti];
    // Do any additional setup after loading the view from its nib.
}

-(void)loadbtn{
     CYUser *user = [CYLoginHttpTool userData].user;
     [CYHttpTool postWithURL:[CYURL shared].getExamineAccount params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
          CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
          if (jsoninfo.isSuccess) {
               NSString *statue = jsoninfo.data;
               if (statue.intValue == 1) {
                    //需要
                    CYAlertView(@"本次提交需要付费，如需提交请点击付费");
                    UIButton *rightButton = [[UIButton alloc]initWithFrame:CGRectMake(0,0,50,30)];
                    rightButton.titleLabel.textColor = [UIColor blackColor];
                    [rightButton addTarget:self action:@selector(fufeiclick) forControlEvents:UIControlEventTouchUpInside];
                    [rightButton setTitle:@"付费" forState:UIControlStateNormal];
                    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightButton];
                    self.navigationItem.rightBarButtonItem= rightItem;

               }else if (statue){
                    if (statue.intValue == 0) {
                         LEBarButtonItem *submit = [[LEBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_done_white_24dp"] andSelImage:nil andTitle:@"提交" target:self action:@selector(submitclick)];
                         self.navigationItem.rightBarButtonItem = submit;
                         
                    }
               }
          }
          
     } failure:^(NSError *error) {
          [MBProgressHUD showMessage:@"网络连接失败"];
          
     }];

}

-(void)fufeiclick{
     CYUser *user = [CYLoginHttpTool userData].user;
     UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"您本次提交需要扣费2元" message:@"请输入交易密码" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确认", nil];
     [alert setAlertViewStyle:UIAlertViewStylePlainTextInput];
     [alert show];
     [alert showAlertViewWithCompleteBlock:^(NSInteger buttonIndex) {
          if (buttonIndex == 1) {
               _dealcodeTF =[alert textFieldAtIndex:0];
               NSString *desstr = [CYDES3Util encrypt:_dealcodeTF.text];
               [CYHttpTool postWithURL:[CYURL shared].saveExamineMoney params:@{@"userId":user.userId,@"token":user.token,@"dealCode":desstr} success:^(id json) {
                    
                    CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
                    if (jsoninfo.isSuccess) {
                         CYAlertView(jsoninfo.message);
                         [[NSNotificationCenter defaultCenter] postNotificationName:@"CYAssetAccountNotification" object:nil userInfo:nil];
                         //付费成功，刷新按钮
                         [[NSNotificationCenter defaultCenter] postNotificationName:@"CYFufeiNotification" object:nil userInfo:nil];
                         
     
                    }else {
                         CYAlertView(jsoninfo.message);
     
                    }
     
               } failure:^(NSError *error) {
                    CYAlertView(@"网络错误");
                    
               }];
          }
     }];
}

-(void)loadstatues{
     NSDictionary *xuelidic = [[NSDictionary alloc] initWithContentsOfFile:@"xueliImage.plist"];
     NSDictionary *huzhaodic = [[NSDictionary alloc] initWithContentsOfFile:@"huzhaoImage.plist"];
     NSDictionary *hunyindic = [[NSDictionary alloc] initWithContentsOfFile:@"hunyinImage.plist"];
     NSDictionary *xinyongdic = [[NSDictionary alloc] initWithContentsOfFile:@"xinyongImage.plist"];
     NSDictionary *hujidic = [[NSDictionary alloc] initWithContentsOfFile:@"hujiImage.plist"];
     NSDictionary *jiazhaodic = [[NSDictionary alloc] initWithContentsOfFile:@"jiazhaoImage.plist"];
     if (xuelidic.count !=0 || huzhaodic.count !=0 || hunyindic.count !=0 || xinyongdic.count !=0 || hujidic.count !=0 || jiazhaodic.count !=0) {
          _gerenleiStatueImage.image = [UIImage imageNamed:@"未标题-2-23"];

     }
     NSDictionary *fangchandic = [[NSDictionary alloc]initWithContentsOfFile:@"fangchanImage.plist"];
     NSDictionary *cheliangdic = [[NSDictionary alloc]initWithContentsOfFile:@"cheliangImage.plist"];
     if (fangchandic.count != 0 || cheliangdic.count !=0) {
          _assetstatueimageView.image = [UIImage imageNamed:@"未标题-2-23"];
          
     }
     
     NSDictionary *gongxindic = [[NSDictionary alloc]initWithContentsOfFile:@"gongxinImage.plist"];
     NSDictionary *getidic = [[NSDictionary alloc]initWithContentsOfFile:@"getiImage.plist"];

     if (gongxindic.count != 0 || getidic.count != 0) {
          _workstatueimageView.image = [UIImage imageNamed:@"未标题-2-23"];
     }
}

-(void)submitclick{
     
     CYUser *user = [CYLoginHttpTool userData].user;
     NSString *userId = user.userId;
     NSString *token = user.token;

     NSFileManager* fileManager=[NSFileManager defaultManager];
     NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
     NSString *uniquePath=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"xueliImage.plist"];
     NSString *uniquePath1=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"huzhaoImage.plist"];
     NSString *uniquePath2=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"hunyinImage.plist"];
     NSString *uniquePath3=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"xinyongImage.plist"];
     NSString *uniquePath4=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"hujiImage.plist"];
     NSString *uniquePath5=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"jiazhaoImage.plist"];
     NSString *uniquePath6=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"fangchanImage.plist"];
     NSString *uniquePath7=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"cheliangImage.plist"];
     NSString *uniquePath8=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"gongxinImage.plist"];
     NSString *uniquePath9=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"getiImage.plist"];
     
     //个人类提交开始
     NSDictionary *xuelidic = [[NSDictionary alloc] initWithContentsOfFile:@"xueliImage.plist"];
     if (xuelidic.count) {
          NSString *zhengshuUrl = [xuelidic objectForKey:@"zhengshuUrl"];
          NSString *shouchiUrl = [xuelidic objectForKey:@"shouchiUrl"];
          if (zhengshuUrl) {
               [_xueliSubmitArray addObject:zhengshuUrl];
          }
          if (shouchiUrl) {
               [_xueliSubmitArray addObject:shouchiUrl];
          }
          for (int i=0; i<_xueliSubmitArray.count; i++) {
               NSDictionary *dic1 = @{@"type":@"1",@"provePicAddress":_xueliSubmitArray[i]};
               [_gerenleiSubmitArray addObject:dic1];
          }
     }
     
     NSDictionary *huzhaodic = [[NSDictionary alloc] initWithContentsOfFile:@"huzhaoImage.plist"];
     if (huzhaodic.count) {
          NSString *baipaiUrl = [huzhaodic objectForKey:@"baipaiUrl"];
          if (baipaiUrl) {
               [_huzhaoSubmitArray addObject:baipaiUrl];
          }
          _qianzhengArray = [huzhaodic objectForKey:@"qianzhengUrl"];
          
          NSString *shouchiUrl = [huzhaodic objectForKey:@"shouchiUrl"];
          if (shouchiUrl) {
               [_huzhaoSubmitArray addObject:shouchiUrl];
          }
          for (int i=0; i<_huzhaoSubmitArray.count; i++) {
               NSDictionary *dic1 = @{@"type":@"2",@"provePicAddress":_huzhaoSubmitArray[i]};
               [_gerenleiSubmitArray addObject:dic1];
          }
          for (int i = 0; i<_qianzhengArray.count; i++) {
               NSDictionary *dic1 = @{@"type":@"2",@"provePicAddress":_qianzhengArray[i]};
               [_gerenleiSubmitArray addObject:dic1];
               
          }
     }
     
     NSDictionary *hunyindic = [[NSDictionary alloc] initWithContentsOfFile:@"hunyinImage.plist"];
     if (hunyindic.count) {
          NSString *baipaiUrl = [hunyindic objectForKey:@"baipaiUrl"];
          if (baipaiUrl) {
               [_hunyinSubmitArray addObject:baipaiUrl];
          }
          NSString *hezhaoUrl = [hunyindic objectForKey:@"hezhaoUrl"];
          if (hezhaoUrl) {
               [_hunyinSubmitArray addObject:hezhaoUrl];
               
          }
          NSString *zinvUrl = [hunyindic objectForKey:@"zinvUrl"];
          if (zinvUrl) {
               [_hunyinSubmitArray addObject:zinvUrl];
          }
          for (int i = 0; i<_hunyinSubmitArray.count; i++) {
               NSDictionary *dic1 = @{@"type":@"3",@"provePicAddress":_hunyinSubmitArray[i]};
               [_gerenleiSubmitArray addObject:dic1];
               
          }
     }
     
     NSDictionary *xinyongdic = [[NSDictionary alloc] initWithContentsOfFile:@"xinyongImage.plist"];
     if (xinyongdic.count) {
          _xinyongArray = [xinyongdic objectForKey:@"xinyongUrl"];
          for (int i = 0; i<_xinyongArray.count; i++) {
               NSDictionary *dic1 = @{@"type":@"4",@"provePicAddress":_xinyongArray[i]};
               [_gerenleiSubmitArray addObject:dic1];
               
          }
     }
     
     NSDictionary *hujidic = [[NSDictionary alloc] initWithContentsOfFile:@"hujiImage.plist"];
     if (hujidic.count) {
          NSString *baipaiUrl = [hujidic objectForKey:@"baipaiUrl"];
          if (baipaiUrl) {
               [_hujiSubmitArray addObject:baipaiUrl];
          }
          _hujijiatingArray = [hujidic objectForKey:@"jiatingUrl"];
          NSString *shouchiUrl = [hujidic objectForKey:@"shouchiUrl"];
          if (shouchiUrl) {
               [_hujiSubmitArray addObject:shouchiUrl];
          }
          
     }
     
     NSDictionary *jiazhaodic = [[NSDictionary alloc] initWithContentsOfFile:@"jiazhaoImage.plist"];
     if (jiazhaodic.count) {
          NSString *zmbaipaiUrl = [jiazhaodic objectForKey:@"zmbaipaiUrl"];
          if (zmbaipaiUrl) {
               [_jiazhaoSubmitArray addObject:zmbaipaiUrl];
          }
          NSString *zmshouchiUrl = [jiazhaodic objectForKey:@"zmshouchiUrl"];
          if (zmshouchiUrl) {
               [_jiazhaoSubmitArray addObject:zmshouchiUrl];
          }
     }

     for (int i = 0; i<_hujijiatingArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"6",@"provePicAddress":_hujijiatingArray[i]};
          [_gerenleiSubmitArray addObject:dic1];
          
     }
     for (int i = 0; i<_hujiSubmitArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"6",@"provePicAddress":_hujiSubmitArray[i]};
          [_gerenleiSubmitArray addObject:dic1];
          
     }
     for (int i = 0; i<_jiazhaoSubmitArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"8",@"provePicAddress":_jiazhaoSubmitArray[i]};
          [_gerenleiSubmitArray addObject:dic1];
          
     }
     CYLog(@"gerenlsubmitarr :%@",_gerenleiSubmitArray);
     
     NSDictionary *fangchandic = [[NSDictionary alloc] initWithContentsOfFile:@"fangchanImage.plist"];
     if (fangchandic.count) {
          _fangchanzmArray = [fangchandic objectForKey:@"fangchanzmUrl"];
          _fangchanhaunjingArray = [fangchandic objectForKey:@"huanjingUrl"];
          _fangchanshouchiArray = [fangchandic objectForKey:@"shouchiUrl"];
     }
     
     NSDictionary *cheliangdic = [[NSDictionary alloc] initWithContentsOfFile:@"cheliangImage.plist"];
     if (cheliangdic.count) {
          _cheliangbaipaiArray = [cheliangdic objectForKey:@"baipaiUrl"];
          _cheliangheyingArray = [cheliangdic objectForKey:@"heyingUrl"];
          _cheliangshouchiArray = [cheliangdic objectForKey:@"shouchiUrl"];
          
     }
     for (int i=0; i<_fangchanshouchiArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"1",@"AssetPicAddress":_fangchanshouchiArray[i]};
          [_assetSubmitArray addObject:dic1];
     }
     for (int i =0; i<_fangchanhaunjingArray.count ; i++) {
          NSDictionary *dic1 = @{@"type":@"3",@"AssetPicAddress":_fangchanhaunjingArray[i]};
          [_assetSubmitArray addObject:dic1];

     }
     for (int i=0; i<_fangchanzmArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"1",@"AssetPicAddress":_fangchanzmArray[i]};
          [_assetSubmitArray addObject:dic1];
     }
     for (int i=0; i<_cheliangbaipaiArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"2",@"AssetPicAddress":_cheliangbaipaiArray[i]};
          [_assetSubmitArray addObject:dic1];
     }
     for (int i=0; i<_cheliangshouchiArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"2",@"AssetPicAddress":_cheliangshouchiArray[i]};
          [_assetSubmitArray addObject:dic1];
     }
     for (int i=0; i<_cheliangheyingArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"2",@"AssetPicAddress":_cheliangheyingArray[i]};
          [_assetSubmitArray addObject:dic1];
     }
     
     
     NSDictionary *gongxindic = [[NSDictionary alloc] initWithContentsOfFile:@"gongxinImage.plist"];
     CYLog(@"gongxindic: %@",gongxindic);
     if (gongxindic.count) {
          NSString *gongpaiUrl = [gongxindic objectForKey:@"gongpaiUrl"];
          if (gongpaiUrl) {
               NSDictionary *dic1 = @{@"type":@"1",@"workPicAddress":gongpaiUrl};
               [_workSubmitArray addObject:dic1];
          }
          NSString *mentouUrl = [gongxindic objectForKey:@"mentouUrl"];
          if (mentouUrl) {
               [_gongxinSubmitArray addObject:mentouUrl];
               
          }
          _gongxinbangonghuanjingArray = [gongxindic objectForKey:@"bangonghuanjingUrl"];
          _gongxindanweihuanjingArray = [gongxindic objectForKey:@"danweihuanjingUrl"];
          
     }
     
     NSDictionary *getidic = [[NSDictionary alloc] initWithContentsOfFile:@"getiImage.plist"];
     CYLog(@"getdic: %@",getidic);
     if (getidic) {
          _getibaipaiUrl = [getidic objectForKey:@"baipaiUrl"];
          _getihuanjingUrl = [getidic objectForKey:@"huanjingUrl"];
          _getimentouUrl =[getidic objectForKey:@"mentouUrl"];
          _getishouchiUrl = [getidic objectForKey:@"shouchiUrl"];
          
     }
     //数据处理开始
     for (int i=0; i<_gongxinSubmitArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"3",@"workPicAddress":_gongxinSubmitArray[i]};
          [_workSubmitArray addObject:dic1];
     }
     for (int i=0; i<_gongxinbangonghuanjingArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"3",@"workPicAddress":_gongxinbangonghuanjingArray[i]};
          [_workSubmitArray addObject:dic1];
     }
     for (int i=0; i<_gongxindanweihuanjingArray.count; i++) {
          NSDictionary *dic1 = @{@"type":@"3",@"workPicAddress":_gongxindanweihuanjingArray[i]};
          [_workSubmitArray addObject:dic1];
          
     }
     
     for (int i=0; i<_getibaipaiUrl.count; i++) {
          NSDictionary *dic1 = @{@"type":@"2",@"workPicAddress":_getibaipaiUrl[i]};
          [_workSubmitArray addObject:dic1];
          
     }
     for (int i=0; i<_getihuanjingUrl.count; i++) {
          NSDictionary *dic1 = @{@"type":@"4",@"workPicAddress":_getihuanjingUrl[i]};
          [_workSubmitArray addObject:dic1];
          
     }
     for (int i=0; i<_getimentouUrl.count; i++) {
          NSDictionary *dic1 = @{@"type":@"4",@"workPicAddress":_getimentouUrl[i]};
          [_workSubmitArray addObject:dic1];
          
     }
     for (int i=0; i<_getishouchiUrl.count; i++) {
          NSDictionary *dic1 = @{@"type":@"2",@"workPicAddress":_getishouchiUrl[i]};
          [_workSubmitArray addObject:dic1];
          
     }
     
     if (_gerenleiSubmitArray.count || _workSubmitArray.count || _assetSubmitArray.count) {
          UIAlertView *noticealert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"请确保所传资料符合规范，不合规将无能获得额度" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
          [noticealert show];
          [noticealert showAlertViewWithCompleteBlock:^(NSInteger buttonIndex) {
               if (buttonIndex == 1) {
                    [MBProgressHUD showMessage:@"处理中..." toView:self.view];
                    
                    if (_gerenleiSubmitArray.count) {
                         
                         //个人类开始
                         NSString *gerenstr = nil;
                         //字符串
                         NSMutableString *gerenstring = [[NSMutableString alloc] init];
                         gerenstr = [gerenstring JSONString];
                         gerenstr = [_gerenleiSubmitArray JSONString];
                         CYLog(@"str=%@",gerenstr);
                         [CYHttpTool postWithURL:[CYURL shared].saveProveInfo params:@{@"userId":userId,@"token":token,@"data":[NSString stringWithString:gerenstr],@"searchPassword":@"",@"weiBo":@""}  success:^(id json) {
                              [_gerenleiSubmitArray removeAllObjects];
                              CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
                              if (jsonInfo.isSuccess) {
                                   _popstatues = @"1";
                                   [[NSNotificationCenter defaultCenter] postNotificationName:@"CYPersonNotification" object:nil userInfo:nil];
                                   if (uniquePath) {
                                        [fileManager removeItemAtPath:uniquePath error:nil];
                                        
                                   }
                                   if (uniquePath1) {
                                        [fileManager removeItemAtPath:uniquePath1 error:nil];
                                        
                                   }
                                   if (uniquePath2) {
                                        [fileManager removeItemAtPath:uniquePath2 error:nil];
                                        
                                   }
                                   if (uniquePath3) {
                                        [fileManager removeItemAtPath:uniquePath3 error:nil];
                                        
                                   }
                                   if (uniquePath4) {
                                        [fileManager removeItemAtPath:uniquePath4 error:nil];
                                        
                                   }
                                   if (uniquePath5) {
                                        [fileManager removeItemAtPath:uniquePath5 error:nil];
                                        
                                   }
                                   [self.navigationController popViewControllerAnimated:YES];
                              }else{
                                   [_gerenleiSubmitArray removeAllObjects];
                              }
                         } failure:^(NSError *error) {
                              [_gerenleiSubmitArray removeAllObjects];
                              CYAlertView(@"网络错误");
                         }];
                         
                    }
                    
                    //个人类提交完成
                    
                    //资产类开始
                    
                    if (_assetSubmitArray.count) {
                         NSString *assetstr = nil;
                         //字符串
                         NSMutableString *assetstring = [[NSMutableString alloc] init];
                         assetstr = [assetstring JSONString];
                         assetstr = [_assetSubmitArray JSONString];
                         [CYHttpTool postWithURL:[CYURL shared].saveAssetInfo params:@{@"userId":userId,@"token":token,@"data":[NSString stringWithString:assetstr],@"homeAddress":@"",@"homeCoordinate":@""}  success:^(id json) {
                              [_assetSubmitArray removeAllObjects];
                              CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
                              if (jsonInfo.isSuccess) {
                                   _popstatues = @"1";
                                   [_assetSubmitArray removeAllObjects];
                                   [[NSNotificationCenter defaultCenter] postNotificationName:@"CYAssetNotification" object:nil userInfo:nil];
                                   if (uniquePath6) {
                                        [fileManager removeItemAtPath:uniquePath6 error:nil];
                                        
                                   }
                                   if (uniquePath7) {
                                        [fileManager removeItemAtPath:uniquePath7 error:nil];
                                        
                                   }
                                   
                                   [self.navigationController popViewControllerAnimated:YES];
                              }else{
                                   [_assetSubmitArray removeAllObjects];
                              }
                         } failure:^(NSError *error) {
                              [_assetSubmitArray removeAllObjects];
                              CYAlertView(@"网络错误");
                         }];
                         
                    }
                    
                    //资产类结束
                    
                    //工作类开始
                    if (_workSubmitArray.count) {
                         NSString *workstr = nil;
                         //字符串
                         NSMutableString *workstring = [[NSMutableString alloc] init];
                         workstr = [workstring JSONString];
                         workstr = [_workSubmitArray JSONString];
                         CYLog(@"workstr = %@",workstr);
                         [CYHttpTool postWithURL:[CYURL shared].saveWorkInfo params:@{@"userId":userId,@"token":token,@"data":[NSString stringWithString:workstr],@"workAddress":@"",@"workCoordinate":@""}  success:^(id json) {
                              [_workSubmitArray removeAllObjects];
                              CYJsonInfo *jsonInfo = [CYJsonInfo objectWithKeyValues:json];
                              if (jsonInfo.isSuccess) {
                                   [_workSubmitArray removeAllObjects];
                                   _popstatues = @"1";
                                   [[NSNotificationCenter defaultCenter] postNotificationName:@"CYWorkNotification" object:nil userInfo:nil];
                                   if (uniquePath8) {
                                        [fileManager removeItemAtPath:uniquePath8 error:nil];
                                        
                                   }
                                   if (uniquePath9) {
                                        [fileManager removeItemAtPath:uniquePath9 error:nil];
                                   }
                              }else{
                                   [_workSubmitArray removeAllObjects];
                              }
                         } failure:^(NSError *error) {
                              [_workSubmitArray removeAllObjects];
                              CYAlertView(@"网络错误");
                         }];
                         
                    }
                    if (_popstatues.intValue == 1) {
                         [MBProgressHUD hideHUDForView:self.view animated:YES];
                         [self.navigationController popViewControllerAnimated:YES];
                         
                    }
                    
                    
               }
          }];

          
     }else{
          CYAlertView(@"您未上传任何照片!");
     }
}
     


- (IBAction)xueliclick:(id)sender {
     CYXueliVC *xueli = [[CYXueliVC alloc]init];
     [self.navigationController pushViewController:xueli animated:YES];
}

- (IBAction)huzhaoclick:(id)sender {
     
     CYHuzhaoVC *huzhao = [[CYHuzhaoVC alloc]init];
     [self.navigationController pushViewController:huzhao animated:YES];
}

- (IBAction)hunyinclick:(id)sender {
     
     CYHunyinVC *hunyin = [[CYHunyinVC alloc]init];
     [self.navigationController pushViewController:hunyin animated:YES];
}
//新的户籍
- (IBAction)xinyongclick:(id)sender {
     
     CYHujiVC *huji = [[CYHujiVC alloc]init];
     [self.navigationController pushViewController:huji animated:YES];
}

- (IBAction)hujiclick:(id)sender {
     
     CYHujiVC *huji = [[CYHujiVC alloc]init];
     [self.navigationController pushViewController:huji animated:YES];
}

- (IBAction)jiazhaoclick:(id)sender {
     
     CYJiazhaoVC *jiazhao = [[CYJiazhaoVC alloc]init];
     [self.navigationController pushViewController:jiazhao animated:YES];
}

- (IBAction)fangchanclick:(id)sender {
     CYFangchanVC *fangchan = [[CYFangchanVC alloc]init];
     [self.navigationController pushViewController:fangchan animated:YES];
}

- (IBAction)cheliangclick:(id)sender {
     
     CYCheliangVC *cheliang = [[CYCheliangVC alloc]init];
     [self.navigationController pushViewController:cheliang animated:YES];
}

- (IBAction)gognxinclick:(id)sender {
     
     CYGongxinVC *gongxin = [[CYGongxinVC alloc]init];
     [self.navigationController pushViewController:gongxin animated:YES];
}

- (IBAction)geticlick:(id)sender {
     
     CYGetiVC *geti = [[CYGetiVC alloc]init];
     [self.navigationController pushViewController:geti animated:YES];
     
}



#pragma mark - 通知
- (void)setupNoti {
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(personalclick)name:CYPersonalNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(assetclick) name:CYNewAssetNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(workclick) name:CYNewWorkNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(fufeitongzhiclick) name:CYFufeiNotification object:nil];
     
}
-(void)fufeitongzhiclick{
     
     CYUser *user = [CYLoginHttpTool userData].user;
     [MBProgressHUD showMessage:nil toView:self.view];
     [CYHttpTool postWithURL:[CYURL shared].getExamineAccount params:@{@"userId":user.userId,@"token":user.token} success:^(id json) {
          [MBProgressHUD hideHUDForView:self.view animated:YES];
          CYJsonInfo *jsoninfo = [CYJsonInfo objectWithKeyValues:json];
          if (jsoninfo.isSuccess) {
               [MBProgressHUD hideHUDForView:self.view animated:YES];
               NSString *statue = jsoninfo.data;
               if (statue.intValue == 1) {
                    //需要
                    LEBarButtonItem *submit = [[LEBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_done_white_24dp"] andSelImage:nil andTitle:@"付费" target:self action:@selector(fufeiclick)];
                    self.navigationItem.rightBarButtonItem = submit;
               }else if (statue){
                    if (statue.intValue == 0) {
                         LEBarButtonItem *submit = [[LEBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"ic_done_white_24dp"] andSelImage:nil andTitle:@"提交" target:self action:@selector(submitclick)];
                         self.navigationItem.rightBarButtonItem = submit;
                         
                    }
               }
          }
          
     } failure:^(NSError *error) {
          [MBProgressHUD hideHUDForView:self.view animated:YES];
          [MBProgressHUD showMessage:@"网络连接失败"];
          
     }];

     
}
-(void)personalclick{
     _gerenleiStatueImage.image = [UIImage imageNamed:@"未标题-2-23"];
     
}
-(void)assetclick{
     _assetstatueimageView.image = [UIImage imageNamed:@"未标题-2-23"];
     
}
-(void)workclick{
     _workstatueimageView.image = [UIImage imageNamed:@"未标题-2-23"];
     
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
